package com.jgzx.controller;

import com.jgzx.common.R;
import com.jgzx.domain.IdDTO;
import com.jgzx.domain.ListVO;
import com.jgzx.domain.dto.EnterprisePublicityDTO;
import com.jgzx.domain.vo.EnterprisePublicityVO;
import com.jgzx.security.annotation.PreAuthorize;
import com.jgzx.security.annotation.ReSubmit;
import com.jgzx.service.EnterprisePublicityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author libo
 * @date 2021/10/22 16:28
 */
@Api(tags = "企业宣传视频")
@RequestMapping("/publicity")
@RestController
public class EnterprisePublicityController {

    @Autowired
    private EnterprisePublicityService enterprisePublicityService;

    @ApiOperation("宣传视频列表")
    @PreAuthorize(hasPermi = "enterprise:publicity:listAll")
    @PostMapping("/listAll")
    public R<ListVO<EnterprisePublicityVO>> listAll() {
        return enterprisePublicityService.listAll();
    }

    @ApiOperation("宣传视频详情")
    @PreAuthorize(hasPermi = "enterprise:publicity:getPublicity")
    @PostMapping("/getPublicity")
    public R<EnterprisePublicityVO> getPublicity(@Valid @RequestBody IdDTO idDTO) {
        return enterprisePublicityService.getPublicity(idDTO);
    }

    @ApiOperation("新增宣传视频")
    @ReSubmit
    @PreAuthorize(hasPermi = "enterprise:publicity:addPublicity")
    @PostMapping("/addPublicity")
    public R<EnterprisePublicityVO> addPublicity(@Valid @RequestBody EnterprisePublicityDTO enterprisePublicityDTO) {
        return enterprisePublicityService.addPublicity(enterprisePublicityDTO);
    }

    @ApiOperation("更新宣传视频")
    @ReSubmit
    @PreAuthorize(hasPermi = "enterprise:publicity:updatePublicity")
    @PostMapping("/updatePublicity")
    public R<EnterprisePublicityVO> updatePublicity(@Valid @RequestBody EnterprisePublicityDTO enterprisePublicityDTO) {
        return enterprisePublicityService.updatePublicity(enterprisePublicityDTO);
    }

    @ApiOperation("删除宣传视频")
    @ReSubmit
    @PreAuthorize(hasPermi = "enterprise:publicity:delPublicity")
    @PostMapping("/delPublicity")
    public R delPublicity(@Valid @RequestBody IdDTO idDTO) {
        return enterprisePublicityService.delPublicity(idDTO);
    }
}
